package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.OrderSetting;
import com.itheima.health.service.OrdersettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Date;


@RestController
@RequestMapping("/ordersetting")
public class OrdersettingController {
    @Autowired
    private OrdersettingService ordersettingService;

    @PostMapping("/upload")
                       //MultipartFile是SpringMVC提供简化上传操作的工具类。
    public Result upload(MultipartFile excelFile) throws IOException {
        ordersettingService.upload(excelFile);
        return new Result(true, MessageConst.IMPORT_ORDERSETTING_SUCCESS);
    }

    @GetMapping("/getOrderSettingByMonth")
    public Result getOrderSettingByMonth(String year,String month){
       return ordersettingService.selectOrderSettingByMonth(year,month);
    }


    @PostMapping("/editNumberByDate")
    public Result editNumberByDate(@RequestBody OrderSetting orderSetting){
        return ordersettingService.editNumberByDate(orderSetting);
    }

}
